home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 1.0 version / MF3DPC / MFINT64.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-07  |  2.3 KB  |  69 lines  |  [TEXT/dosa]

  1. #ifndef MF3DINT64_H
  2. #define    MF3DINT64_H
  3. /*==============================================================================
  4.  *
  5.  *    File:        MFINT64.H
  6.  *
  7.  *    Function:    If the compiler/platform does not handle 64-bit numbers,
  8.  *                we will need some helper math routines.
  9.  *
  10.  *    Version:    Metafile:    Version 1.0 3DMF files
  11.  *                Package:    Release #2 of this code
  12.  *
  13.  *    Author(s):    Rick Wong (RWW), Duet Development Corp.
  14.  *                John Kelly (JRK), Duet Development Corp.
  15.  *
  16.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  17.  *
  18.  *    Change History (most recent first):
  19.  *        FB7_JRK    Pragma macros
  20.  *        Fabio    Changed file name to 8 characters
  21.  *        F2F_RWW    File created.
  22.  *==============================================================================
  23.  */
  24. #if defined(applec) || defined(__MWERKS__) || defined(THINK_C)
  25. #pragma once
  26. #endif
  27.  
  28. #include "MFSYSTYP.H"
  29. #include "MFASSERT.H"
  30.  
  31. #define    Int32ToInt64(lnum,int64)    {    if ((lnum) >= 0)                    \
  32.                                             (int64).hi = 0;                    \
  33.                                         else                                \
  34.                                             (int64).hi = -1;                \
  35.                                         (int64).lo = (MF3DUns32)(lnum);        \
  36.                                     }
  37. #define    Int32ToUns64(lnum,uns64)    {    if ((lnum) >= 0)                    \
  38.                                             (uns64).hi = 0;                    \
  39.                                         else                                \
  40.                                             (uns64).hi = ULONG_MAX;            \
  41.                                         (uns64).lo = (MF3DUns32)(lnum);        \
  42.                                     }
  43.  
  44. #define CompareInt64(i1, i2)                                                \
  45.                         (((i1).hi - (i2).hi) != 0 ?                            \
  46.                             (((MF3DInt32)(i1).hi) - ((MF3DInt32)(i2).hi)) :    \
  47.                             (((MF3DInt32)(i1).lo) - ((MF3DInt32)(i2).lo))    \
  48.                         )
  49.  
  50. #define    AssignInt64(idst, isrc)        (idst).hi = (isrc).hi,                    \
  51.                                     (idst).lo = (isrc).lo;
  52.  
  53. #define    SetInt64ToZero(idst)        (idst).hi = 0, (idst).lo = 0;
  54.  
  55. /* This macro should only be used if appropriate range checks are made        */
  56. #define    Uns64ToUns32(int64,lnum)    MFASSERT((int64).hi == 0), (lnum) = (int64).lo
  57.  
  58. /* Calculate i1 - i2 (assumes that i1 >= i2), returning result in an Uns32    */
  59. /* Also assumes that result will fit into an Uns32.                            */
  60. #define    SubtractUns64(i1, i2)                                                \
  61.                     (    MFASSERT((i1).hi == (i2).hi ||                    \
  62.                         ((i1).hi == ((i2).hi + 1) && (i2).lo > (i1).lo)),    \
  63.                         ( ((i1).hi - (i2).hi) != 0 ?                        \
  64.                         ((i1).lo + (MF3DUns32)(-(MF3DInt32)((i2).lo))) :    \
  65.                         ((i1).lo - (i2).lo) )                                \
  66.                     )
  67.  
  68. #endif
  69.